//判断集合成员
//unordered_set的使用
#include<bits/stdc++.h>
using namespace std;

int main()
{
	int k = 0;
	cin >> k;
	while(k--)
	{
		int n = 0;
		cin >> n;
		unordered_set<int> uns;
		for(int i = 1; i <= n; i++)
		{
			int tmp = 0;
			cin >> tmp;
			uns.insert(tmp);
		}	
		int m = 0;
		cin >> m;
		if(uns.find(m) != uns.end()) cout << "YES" <<endl;
		else  cout << "NO" << endl;
	}
	return 0;
}
